<extend name="./Application/Common/View/block/base.php" />
<block name="header">
    <include file="./Application/Admin/View/block/easyui_header.php" />
    <include file="./Application/Admin/View/block/amap_header.php" />
    <link href="__PUBLIC__/css/Content/index.css" rel="stylesheet" type="text/css" />
    <style>
        #dg{
            height: 100%;;
        }
    </style>
    <script>
        $(function(){
            $('#pumpStationTree').tree({
                method: 'get',
                checkbox : false,
                lines: true,
                url : '__URL__/get_pump_station_tree',
                checkbox:true,
                onLoadSuccess: function (node, data) {
                    $('#tabs_pumpstation').tabs({height:$('#subTabCtrl_1').height()-40,width:$('#subTabCtrl_1').width()-50});
                    var firstLeaf=null;
                    if($('#pumpstation_id').val()=="")
                        firstLeaf = getFirstLeafNode();
                    else
                        firstLeaf=$('#pumpStationTree').tree('find', parseInt($('#pumpstation_id').val()));

                    $('#pumpStationTree').tree('select',firstLeaf.target);
                    var id = firstLeaf.id;
//                    switchPumpStation(id);
                    $(".validatebox-tip").remove();
                    $('#btnList').linkbutton('enable');

                    $('#btnList').linkbutton('enable');
                }
            });

        });

        function getFirstLeafNode() {
            var node = $('#pumpStationTree').tree('getRoot');
            var children=null;
            while(!$('#pumpStationTree').tree('isLeaf', node.target)) {
                if (node){
                    children = $('#pumpStationTree').tree('getChildren', node.target);
                } else {
                    children = $('#pumpStationTree').tree('getChildren');
                }
                if (children!=null && children.length>0)
                    node = children[0];
            }
            return node;
        }



        function switchPumpStation() {
            var s = getChecked();
            if(s==''){
                $.messager.show({title:'提示',msg:'请勾选泵站',showType:'slide'});
                return;
            }
            $('#pumpstation_id').val(s);
            //清空所有form
            $('form').form('clear');
            $("input[name='pumpid']").val(s);
            $("input[name='ischecked']").val(1);
            //刷新说有表格
//            $('#grid_pump').datagrid({queryParams:{'pumpid':$('#pumpstation_id').val(),page:1,rows:10}});
            $('#grid_pump_log').datagrid({queryParams:{'ps_id':$('#pumpstation_id').val(),'ischecked':1,page:1,rows:10}});
//            $('#grid_machine').datagrid({queryParams:{'pumpid':$('#pumpstation_id').val(),page:1,rows:10}});
            $('#grid_machine_log').datagrid({queryParams:{'ps_id':$('#pumpstation_id').val(),'ischecked':1,page:1,rows:10}});
//            $('#grid_waterele').datagrid({queryParams:{'pumpid':$('#pumpstation_id').val(),page:1,rows:10}});
            $('#grid_waterele_log').datagrid({queryParams:{'ps_id':$('#pumpstation_id').val(),'ischecked':1,page:1,rows:10}});
            $('#grid_weather_log').datagrid({queryParams:{'facilities_type':1,'facilities_id':$('#pumpstation_id').val(),page:1,rows:20}});
            //刷新需要的控件
            $('.pump_select').combobox('reload','/Manage/AdminPumpPump/get_all_pump?pumpid='+id);
            $('.machine_select').combobox('reload','/Manage/AdminPumpMachine/get_all_machine?pumpid='+id);
            $('.waterele_select').combobox('reload','/Manage/AdminPumpWaterele/get_all_waterele?pumpid='+id);



//            clearPumpstationForm();
//            editPumpstation($('#pumpstation_id').val());
        }

        function export_xls(){
            if(getChecked()==''){
                $.messager.show({title:'提示',msg:'请勾选需要导出的泵站',showType:'slide'});
                return;
            }
            $('#yy_window').window('open');
        }

        function bz_xls(){
            var s = getChecked();
            if(s==''){
                $.messager.show({title:'提示',msg:'请勾选需要导出的泵站',showType:'slide'});
                return;
            }
            $('#zb_window').window('open');
        }

        function getChecked(){
            var nodes = $('#pumpStationTree').tree('getChecked');
            var s = '';
            for(var i=0; i<nodes.length; i++){
                if (!$('#pumpStationTree').tree('isLeaf', nodes[i].target)||isNaN(nodes[i].id)) {
                    continue;
                }
                if (s != '') s += ',';
                s += nodes[i].id;
            }
            return s;
        }

    </script>
</block>
<block name="bdoy">
    <body>
    <input type="hidden" id="dsfg" name="dsfg" value="dsfg"/>
    <input type="hidden" id="pumpstation_id" name="pumpstation_id"/>
    <div class="easyui-layout" style="width:100%;height: 500px;"  fit="true">
        <div data-options="region:'west',split:true" title="{:LANG('pump_station')}" style="width:240px;">
            <div id="treeToolBar" style="background:#fafafa;padding:2px;height:auto">
                <a id="btnAdd3" href="#" class="easyui-linkbutton"  onclick="switchPumpStation()" iconCls="icon-ok" plain="true">确定选中</a>
                <a id="btnDel3" href="#" class="easyui-linkbutton"  onclick="export_xls()" iconCls="icon-xls" plain="true">运营管理部报表</a>
                <a id="bz_export" href="#" class="easyui-linkbutton"  onclick="bz_xls()" iconCls="icon-xls" plain="true">泵站分公司报表</a>
            </div>
            <ul id="pumpStationTree" class="easyui-tree" ></ul>
        </div>
        <div data-options="region:'center'">
            <div class="easyui-tabs" id="tabCtrl" fit="true" border="false">
<!--                <div title="泵站基础信息" fit=true  closable="false" style="padding:10px;">-->
<!--                    <div id="subTabCtrl_1" class="easyui-tabs" fit="true" plain="true" >-->
<!--                        <div title="泵站基本信息" fit=true style="padding:10px;" href="__URL__/base_info" loadingMessage="{:LANG('loading')}"></div>-->
<!--                    </div>-->
<!--                </div>-->
                <div title="泵机运行记录"  closable="false" style="padding:10px;">
                    <div class="easyui-tabs" fit="true" plain="true" style="height:100px;width:300px;" tools="#pumpmonth_toolbars">
<!--                        <div title="泵机列表" style="padding:10px;" href="__URL__/pump_pump" loadingMessage="{:LANG('loading')}" fit="true"></div>-->
                        <div title="泵机运行记录" style="padding:10px;" href="__URL__/log_show_pump_index" loadingMessage="{:LANG('loading')}" fit="true"></div>
                    </div>
                </div>
                <div title="格栅机运行记录"  closable="false" style="padding:10px;">
                    <div class="easyui-tabs" fit="true" plain="true" style="height:100px;width:300px;" tools="#pumpmonth_toolbars">
<!--                        <div title="格栅机列表" style="padding:10px;" href="__URL__/pump_machine" loadingMessage="{:LANG('loading')}" fit="true"></div>-->
                        <div title="格栅机运行记录" style="padding:10px;" href="__URL__/log_show_machine_index" loadingMessage="{:LANG('loading')}" fit="true"></div>
                    </div>
                </div>
                <div title="水电表运行记录" closable="false" style="padding:10px;">
                    <div tools="#pwvl_toolbars" class="easyui-tabs" fit="true" plain="true" style="height:100px;width:300px;">
<!--                        <div title="水电表" style="padding:10px;" href="__URL__/pump_waterele" loadingMessage="{:LANG('loading')}" fit="true"></div>-->
                        <div title="水电表运行记录" style="padding:10px;" href="__URL__/log_show_waterele_index" loadingMessage="{:LANG('loading')}" fit="true"></div>
                    </div>
                </div>
                <div title="雨情记录" closable="false"  style="padding:10px;">
                    <div class="easyui-tabs" fit="true" plain="true" style="height:100px;width:300px;">
                        <div title="雨情记录" style="padding:10px;" href="__URL__/log_show_weather_index" loadingMessage="{:LANG('loading')}" fit="true"></div>
                    </div>
                </div>
            </div>
        </div>

    </div>
    </div>

    <div id="gtx_window" class="easyui-window" closed="true" title="选择日期" data-options="modal:true" style="width:300px;height:150px;padding:0px;overflow: hidden;">
        <form id="form">
            <table class="form-table">
                <tr>
                    <td width="100" align="center">选择日期：</td>
                    <td><input id="start_date_m" class="easyui-datebox textbox" required data-options="validType:'md[\'10/11/2012\']',prompt:'{:LANG('pls_slet')}{:LANG('start_date')}'"></td>
                </tr>
                <tr>
                    <td align="center" colspan="2">
                        <a href="javascript:split_month()" class="easyui-linkbutton" style="width:120px">{:LANG('export')}</a>
                    </td>
                </tr>
            </table>
        </form>
    </div>
    <div id="pump_type_window" class="easyui-window" closed="true" title="选择需要导出泵机类型" data-options="modal:true" style="width:300px;height:150px;padding:0px;overflow: hidden;">
        <table class="form-table">
            <tr>
                <td>
                    <div>
                        <label for="rain_pump">雨水泵</label><input type="checkbox" id="rain_pump" value="1" checked="checked"/>
                        <label for="dran_pump">污水泵</label><input type="checkbox" id="dran_pump" value="1" checked="checked"/>
                    </div>
                </td>
            </tr>
            <tr>
                <td align="center" colspan="2">
                    <a href="javascript:split_yy_day()" class="easyui-linkbutton" style="width:200px">导出报表</a>
                </td>
            </tr>
        </table>

    </div>
    <div id="yy_window" class="easyui-window" closed="true" title="导出运营管理部报表" data-options="modal:true" style="width:220px;height:250px;padding:0px;overflow: hidden;">
        <table class="form-table">
            <tr>
                <td>选择日期：</td>
            </tr>
            <tr>
                <td><input id="yy_start_date" class="easyui-datebox textbox" required data-options="validType:'md[\'10/11/2012\']',prompt:'{:LANG('pls_slet')}{:LANG('start_date')}'"></td>
            </tr>
            <tr>
                <td align="center" colspan="2">
                    <a href="javascript:split_yy_week1()" class="easyui-linkbutton" style="width:200px">泵站运行情况周报表_1</a>
                </td>
            </tr>
            <tr>
                <td align="center" colspan="2">
                    <a href="javascript:$('#pump_type_window').window('open')" class="easyui-linkbutton" style="width:200px">泵站泵机日运行情况报表</a>
                </td>
            </tr>
            <tr>
                <td align="center" colspan="2">
                    <a href="javascript:split_yy_week2()" class="easyui-linkbutton" style="width:200px">泵站运行情况周报表_2</a>
                </td>
            </tr>
            <tr>
                <td align="center" colspan="2">
                    <a href="javascript:manage_exp_station_month_total()" class="easyui-linkbutton" style="width:200px">泵站月报表总表</a>
                </td>
            </tr>
        </table>

    </div>
    <div id="zb_window" class="easyui-window" closed="true" title="导出泵站分公司报表" data-options="modal:true" style="width:300px;height:250px;padding:0px;overflow: hidden;">
        <table class="form-table">
            <tr>
                <td width="100" align="center">起始日期：</td>
                <td><input id="start_date" class="easyui-datetimebox textbox" required data-options="validType:'md[\'10/11/2012\']',prompt:'{:LANG('pls_slet')}{:LANG('start_date')}'"></td>
            </tr>
            <tr>
                <td width="100" align="center">结束日期：</td>
                <td><input id="end_date" class="easyui-datetimebox textbox" required data-options="validType:'md[\'10/11/2012\']',prompt:'{:LANG('pls_slet')}{:LANG('end_date')}'"></td>
            </tr>
        </table>
        <table class="form-table">
            <tr>
                <td align="center" colspan="2">
                    <a href="javascript:split_pump()" class="easyui-linkbutton" style="width:120px">泵机运行记录表</a>
                </td>
                <td align="center" colspan="2">
                    <a href="javascript:split_machine()" class="easyui-linkbutton" style="width:120px">格栅机运行记录表</a>
                </td>

            </tr>
            <tr>
                <td align="center" colspan="2">
                    <a href="javascript:split_waterele()" class="easyui-linkbutton" style="width:120px">用电用水记录表</a>
                </td>
                <td align="center" colspan="2">
                    <a href="javascript:split_reglog()" class="easyui-linkbutton" style="width:120px">交接班记录表</a>
                </td>
            </tr>
            <tr>
                <td align="center" colspan="2">
                    <a href="javascript:$('#gtx_window').window('open')" class="easyui-linkbutton" style="width:120px">月运行记录表</a>
                </td>
            </tr>
        </table>

    </div>
    </body>
</block>
<block name="footExtendJs">
    <script type="text/javascript">
        $(function(){

        });


        function split_pump(){
            var temp_ids = getChecked();
//            temp_ids = temp_ids.split(",");
            export_pump(temp_ids);
//            for(var i=0;i<temp_ids.length;i++){
//                export_pump(temp_ids[i]);
//            }
        }

        function export_pump(id){
            var start = $('#start_date').datetimebox('getValue');
            var end = $('#end_date').datetimebox('getValue');
            var url = '/Manage/AdminPumpPump/export_record?pid='+id+'&start='+start+'&end='+end;
            window.open(url);
        }

        function split_machine(){
            var temp_ids = getChecked();
//            temp_ids = temp_ids.split(",");
            export_machine(temp_ids);
//            for(var i=0;i<temp_ids.length;i++){
//                export_machine(temp_ids[i]);
//            }
        }

        function export_machine(id){
            var start = $('#start_date').datetimebox('getValue');
            var end = $('#end_date').datetimebox('getValue');
            var url = '/Manage/AdminPumpMachine/export_record?pid='+id+'&start='+start+'&end='+end;
            window.open(url);
        }

        function split_waterele(){
            var temp_ids = getChecked();
            export_waterele(temp_ids);
//            temp_ids = temp_ids.split(",");
//            for(var i=0;i<temp_ids.length;i++){
//                export_waterele(temp_ids[i]);
//            }
        }

        function export_waterele(id){
            var start = $('#start_date').datetimebox('getValue');
            var end = $('#end_date').datetimebox('getValue');
            var url = '/Manage/AdminPumpWaterele/export_record?pid='+id+'&start='+start+'&end='+end;
            window.open(url);
        }

        function split_reglog(){
            var temp_ids = getChecked();
            temp_ids = temp_ids.split(",");
            for(var i=0;i<temp_ids.length;i++){
                export_reglog(temp_ids[i]);
            }
        }

        function export_reglog(id){
            var start = $('#start_date').datetimebox('getValue');
            var end = $('#end_date').datetimebox('getValue');
            var url = '/Manage/AdminMobileAdmin/export_record?pid='+id+'&start='+start+'&end='+end+'&station=station';
            window.open(url);
        }

        function split_month(){
            var temp_ids = getChecked();
            temp_ids = temp_ids.split(",");
            for(var i=0;i<temp_ids.length;i++){
                export_month(temp_ids[i]);
            }
        }

        function export_month(id){
            var start = $('#start_date_m').datetimebox('getValue');
            var url = '/Manage/OnlyExport/station_month?pid='+id+'&start='+start;
            window.open(url);
        }

        function split_yy_week1(){
            var temp_ids = getChecked();
            export_yy_week1(temp_ids);
        }

        function export_yy_week1(ids){
            var start = $('#yy_start_date').datetimebox('getValue');
            var url = '/Manage/OnlyExport/pump_week_1?ids='+ids+'&start='+start;
            window.open(url);
        }

        function split_yy_week2(){
            var temp_ids = getChecked();
//            temp_ids = temp_ids.split(",");
//            for(var i=0;i<temp_ids.length;i++){
//                export_yy_week2(temp_ids[i]);
//            }
            export_yy_week2(temp_ids);
        }

        function export_yy_week2(ids){
            var start = $('#yy_start_date').datetimebox('getValue');
            var url = '/Manage/OnlyExport/pump_week_2?ids='+ids+'&start='+start;
            window.open(url);
        }

        function split_yy_day(){
            var temp_ids = getChecked();
            temp_ids = temp_ids.split(",");
            export_yy_day(temp_ids);
        }

        function export_yy_day(ids){
            var start = $('#yy_start_date').datetimebox('getValue');
            var rain = $('#rain_pump').prop('checked');
            var dran = $('#dran_pump').prop('checked');
            var url = '/Manage/OnlyExport/pump_day?ids='+ids+'&start='+start+'&rain='+rain+'&dran='+dran;
            window.open(url);
        }

        function manage_exp_station_month_total(){
            var start = $('#yy_start_date').datetimebox('getValue');
            var url = '/Manage/OnlyExport/station_month_total?start='+start;
            window.open(url);
        }
    </script>
</block>
